package com.jmyd.commons.redis.repository;


import java.time.Duration;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * Created by samphin on 2017/10/24.
 *
 * @param <T>
 */
public interface BaseRedisRepository<T> {

    Long incrementAndGet(String key);

    void save(String key, T t);

    void save(String key, T t, Date expireDate);

    void save(String key, T t, long expireTime, TimeUnit timeUnit);

    void save(String key, T t, Duration duration);

    T get(String key);

    boolean hasKey(String key);

    void saveAsList(final String key, List<T> list, long expireTime, TimeUnit timeUnit);

    Long saveAsList(final String key, List<T> list);

    void rightPush(String key, T value);

    void leftPop(String key);

    void delete(String key);

    void delete(Collection key);

    void remove(final String key, long num, T t);

    void saveAsHash(final String key, final String hashKey, T t);

    void saveAsHash(final String key, final String hashKey, T t, long expireTime, TimeUnit timeUnit);

    List<T> getList(final String key, Long start, Long end);

    T getObject(final String key, final String hashKey);

    Map<String, T> hGetAll(String key);

}
